cmake_minimum_required(VERSION 3.10)  # 指定CMake的最小版本要求
project(boost-svr)  # 设置项目名称

# 设置默认的构建类型为Debug
SET(CMAKE_BUILD_TYPE Debug)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

set(CMAKE_CXX_STANDARD 17)

set(CMAKE_JOB_POOL_COMPILE compile_job_pool)
set(CMAKE_JOB_POOLS compile_job_pool=1)  # 限制为1线程

# 包含项目中的头文件目录
include_directories(
    /usr/include/lua5.3
    /usr/local/include/google/protobuf
    ${Boost_INCLUDE_DIRS} # 包含Boost头文件目录
    ${CMAKE_SOURCE_DIR}/external/sol2/include
    ${CMAKE_SOURCE_DIR}/share/network
    ${CMAKE_SOURCE_DIR}/share/proto
    ${CMAKE_SOURCE_DIR}/share/utils
    ${CMAKE_SOURCE_DIR}/src
  )

file(GLOB PROTO_SRC ${CMAKE_SOURCE_DIR}/share/proto/*.cc)
file(GLOB SOURCES [^.]*.cpp [^.]*.h)

# 查找 Lua
find_package(Lua REQUIRED)

# 查找 protobuf 库
find_package(Protobuf REQUIRED)

# 查找Boost库
find_package(Boost REQUIRED COMPONENTS system)

# 添加要编译的源文件
add_executable(svr ${SOURCES} ${PROTO_SRC})

# 链接Boost库
target_link_libraries(svr ${Boost_LIBRARIES})

# 链接 Lua 库
target_link_libraries(svr ${LUA_LIBRARIES})

# 链接 protobuf 库
target_link_libraries(svr ${PROTOBUF_LIBRARY})